package org.web2024.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.web2024.dao.Result;
import org.web2024.service.PublicService;

@RestController
@RequestMapping("/public")
public class PublicController {
    @Autowired
    private PublicService publicService;
    @PostMapping("/getTerms")
    public Result getTerms()
    {
        if(publicService.getTerms().getData()==null){
            return Result.fail("暂无学期");
        }
        return publicService.getTerms();
    }
    @GetMapping("/getCurrentTerm")
    public Result getCurrentTerm()
    {
        return Result.success(publicService.currentTerm());
    }
}
